package com.wang.jmonkey.modules.system.model.param;

import cn.hutool.core.bean.BeanUtil;
import com.wang.jmonkey.modules.system.model.entity.SystemMenuEntity;
import com.wang.jmonkey.modules.system.model.entity.SystemResourceEntity;
import com.wang.jmonkey.modules.system.model.enums.SystemResourceTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @Description 菜单配置信息
 * @Author HeJiawang
 * @Date 2021/5/21 21:59
 */
@Data
@Accessors(chain = true)
public class SystemMenuParam extends SystemMenuEntity {

    /**
     * 父资源ID，指向system_resource.id
     */
    private Long parentId;

    /**
     * convertToEntity
     * @return entity
     */
    public SystemMenuEntity convertToEntity() {
        SystemMenuEntity entity = new SystemMenuEntity();
        BeanUtil.copyProperties(this, entity);

        return entity;
    }

    /**
     * convertToResource
     * @return SysResource
     */
    public SystemResourceEntity convertToResource() {
        SystemResourceEntity resource = new SystemResourceEntity()
                .setType(SystemResourceTypeEnum.Menu)
                .setParentId(this.parentId)
                .setResourceId(this.getId());

        return resource;
    }
}
